package com.dure.hotmemory.scenes;

import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.dure.hotmemory.MainActivity;
import com.dure.hotmemory.bean.Bean;
import com.dure.hotmemory.drawview.BaseSurfaceView;


/**
 * Created by dure on 2017/4/7.
 */

public abstract class BaseScene {

    public BaseSurfaceView baseSurfaceView;
    private boolean isShowing;
    public boolean dataInited;
    public float left, top;
    public View sceneView;
    public MainActivity activity;
    public boolean initDataFinished;
    public Context context;
    public float moveSpeed;


    public BaseScene(BaseSurfaceView baseSurfaceView) {
        Log.d("lesleixz", "base scene constructor");
        this.baseSurfaceView = baseSurfaceView;
        context = baseSurfaceView.getContext();
        activity = (MainActivity) context;
        isShowing = true;
    }

    // 用于控制是否显示背景, 默认显示
    private boolean showBg = true;

    /**
     * 用于初始化数据
     */
    public void initData(){}

    /**
     * 用于控制绘制所需数据
     */
    public void handleData(){}

    /**
     * 用于绘制图形
     */
    public void handleDraw(Canvas canvas){

    }

    public void handleDown(PointF pointF) {
        if (pointF == null){
            return;
        }
    }

    ;

    public void handleUp(PointF pointF) {
        if (pointF == null){
            return;
        }
    }

    ;

    public void handleMove(PointF pointF) {
        if (pointF == null){
            return;
        }
    }

    ;

    /**
     * 处理返回操作
     */
    public void handleBack() {
    }

    /**
     * 处理触屏事件
     */
    public void handleTouch(MotionEvent event) {
    }

    /**
     * 处理点击事件
     */
    public void viewClicked(View view) {
    }

    public void onRestart() {
    }

    public boolean isShowBg() {
        return showBg;
    }

    public void setShowBg(boolean showBg) {
        this.showBg = showBg;
    }

    public int getViewWidth() {
        return baseSurfaceView.getWidth();
    }

    public int getViewHeight() {
        return baseSurfaceView.getHeight();
    }

    public boolean isShowing() {
        return isShowing;
    }

    public void setShowing(boolean showing) {
        isShowing = showing;
    }

    public BaseSurfaceView getBaseSurfaceView() {
        return baseSurfaceView;
    }

    public void handleRequestSuccess(Bean bean) {
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {

    }

    public void permissionGranted(int requestCode){

    }


}
